package teleradiologia.service;

import java.util.List;

import teleradiologia.domain.Radiologylab;
import teleradiologia.domain.Technician;
import teleradiologia.domain.Person;
import teleradiologia.repository.PersonDao;
import teleradiologia.repository.RadlabmanagerDao;
import teleradiologia.repository.TechnicianDao;

public class TechnicianManipulatorImpl implements TechnicianManipulator {


	private TechnicianDao technicianDao;
	private PersonDao personDao;
	
	@Override
	public String create(Technician technician, Person person, Radiologylab radiologylab) {
		long id= this.personDao.create(person);
		technician.setPerson(this.personDao.getById(id));
		technician.setRadiologylab(radiologylab);
		return this.technicianDao.create(technician);
	}

	@Override
	public void delete(Technician technician) {
		this.technicianDao.delete(technician);
		this.personDao.delete(technician.getPerson());
	}

	@Override
	public Technician getByNip(String nip) {
		return this.technicianDao.getByNip(nip);
	}

	@Override
	public void setTechnicianDao(TechnicianDao technicianDao) {
		this.technicianDao = technicianDao;
	}
	
	public void setPersonDao(PersonDao personDao) {
		this.personDao = personDao;
	}

	@Override
	public void update(Technician technician) {
		this.personDao.update(technician.getPerson());
		this.technicianDao.update(technician);
	}

	@Override
	public Technician geByIdPerson(long idPerson) {
		return this.technicianDao.getByIdPerson(idPerson);
	}

	@Override
	public List<Technician> getAll() {
		return this.technicianDao.getAll();
	}

	@Override
	public List<Technician> getAllByKrsnumber(String krsnumber) {
		return this.technicianDao.getAllByKrsnumber(krsnumber);
	}
}
